/***********************************************************************************
@file  
@author 
@brief  
***********************************************************************************/
#ifndef _MID_GPIO_H
#define _MID_GPIO_H
/* Private includes ----------------------------------------------------------*/
#include "main.h"
/* Private define ------------------------------------------------------------*/
#define LED1_PORT         GpioPortB
#define LED1_PIN          GpioPin2 
#define LED2_PORT         GpioPortC
#define LED2_PIN          GpioPin5
#define LED3_PORT         GpioPortC
#define LED3_PIN          GpioPin4
#define LED4_PORT         GpioPortA
#define LED4_PIN          GpioPin7

#define KEY_EX_PORT       GpioPortB
#define KEY_EX_PIN        GpioPin6
#define KEY_UP_PORT       GpioPortB
#define KEY_UP_PIN        GpioPin5
#define KEY_RIGHT_PORT    GpioPortB
#define KEY_RIGHT_PIN     GpioPin4

#define LORA_M0_PORT      GpioPortD
#define LORA_M0_PIN       GpioPin2
#define LORA_M1_PORT      GpioPortC
#define LORA_M1_PIN       GpioPin12

#define POW_PORT          GpioPortB//电池使能脚
#define POW_PIN           GpioPin11

#define SENSOR_PORT       GpioPortB
#define SENSOR_PIN        GpioPin7

#define ALARM_PORT        GpioPortB
#define ALARM_PIN         GpioPin1

#define VIR_PORT          GpioPortB
#define VIR_PIN           GpioPin10

#define WT588_CLK_PORT    GpioPortB
#define WT588_CLK_PIN     GpioPin8

#define WT588_DAT_PORT    GpioPortB
#define WT588_DAT_PIN     GpioPin9

#define IIC_SCL_PORT          GpioPortD
#define IIC_SCL_PIN           GpioPin6

#define IIC_SDA_PORT          GpioPortD
#define IIC_SDA_PIN           GpioPin7

#define ADX_EXT_PORT          GpioPortD
#define ADX_EXT_PIN           GpioPin4

#define led_green(n)      ((n) ? Gpio_SetIO(LED4_PORT, LED4_PIN)       : Gpio_ClrIO(LED4_PORT, LED4_PIN))
#define led_yellow(n)     ((n) ? Gpio_SetIO(LED3_PORT, LED3_PIN)       : Gpio_ClrIO(LED3_PORT, LED3_PIN))
#define led_red1(n)       ((n) ? Gpio_SetIO(LED2_PORT, LED2_PIN)       : Gpio_ClrIO(LED2_PORT, LED2_PIN))
#define led_red2(n)       ((n) ? Gpio_SetIO(LED1_PORT, LED1_PIN)       : Gpio_ClrIO(LED1_PORT, LED1_PIN))


#define sensor_en(n)      ((n) ? Gpio_SetIO(SENSOR_PORT, SENSOR_PIN)   : Gpio_ClrIO(SENSOR_PORT, SENSOR_PIN))
#define bat_en(n)         ((n) ? Gpio_SetIO(POW_PORT, POW_PIN)         : Gpio_ClrIO(POW_PORT, POW_PIN))
#define alarm_en(n)       ((n) ? Gpio_SetIO(ALARM_PORT, ALARM_PIN)     : Gpio_ClrIO(ALARM_PORT, ALARM_PIN))
#define infrared_en(n)    ((n) ? Gpio_SetIO(VIR_PORT, VIR_PIN)         : Gpio_ClrIO(VIR_PORT, VIR_PIN))


#define lora_m0(n)        ((n) ? Gpio_SetIO(LORA_M0_PORT, LORA_M0_PIN) : Gpio_ClrIO(LORA_M0_PORT, LORA_M0_PIN))
#define lora_m1(n)        ((n) ? Gpio_SetIO(LORA_M1_PORT, LORA_M1_PIN) : Gpio_ClrIO(LORA_M1_PORT, LORA_M1_PIN))

#define sensor_en_read    Gpio_ReadOutputIO(SENSOR_PORT,SENSOR_PIN)
#define alarm_en_read     Gpio_ReadOutputIO(ALARM_PORT,ALARM_PIN)
#define infrared_en_read  Gpio_ReadOutputIO(VIR_PORT,VIR_PIN)


#define button_ex          Gpio_GetInputIO(KEY_EX_PORT,    KEY_EX_PIN)
#define button_up          Gpio_GetInputIO(KEY_UP_PORT,    KEY_UP_PIN)
#define button_right       Gpio_GetInputIO(KEY_RIGHT_PORT, KEY_RIGHT_PIN)

/* unused port define ------------------------------------------------------------*/

/* Private typedef -----------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function ----------------------------------------------------------*/

extern void gpio_out_init(void);
extern void gpio_in_init(void);
extern void gpio_de_init(void);
extern void button_gpio_init(void);
extern void button_gpio_deinit(void);
extern void swd_deinit();
#endif

/**************************** (C) COPYRIGHT CX*****END OF FILE**********************/

